<script src="/javascripts/validation/jquery.validate.js" type="text/javascript"></script>
<script src="/javascripts/validation/validate_order.js" type="text/javascript"></script>
<div class='form'>
  <% form_for @order do |f| %>
    <%= f.error_messages %>
    <p>
      <label for="order_paytype"><span style="color:red;">* </span>送货地址</label>[<a href="/users/<%=session[:user_id]%>/addresses">管理</a>]
    <div class="address">
      <% if @order_owen.addresses.size > 0 %>
        <% @order_owen.addresses.each do |a| %>
          <%=radio_button("order", "address_id",a.id,{:onclick=>"changeHiddenValue(this.value);"})%><%=a.title%>  联系人: <%= a.receiver%>  联系电话: <%= a.tel%> <%= a.mobile %><span></span> <br />
        <% end %>

      <%else%>
        您还没有送货地址,请先<a href="/users/<%=session[:user_id]%>/addresses/new" >添加送货地址</a>
      <%end%>
    </div>
  </p>

  <p>
    <label for="order_logistic_id"><span style="color:red;">* </span>物流方式</label>
    <%=select("order", "logistic_id",Logistic.find(:all).collect {|l|[l.name,l.id ]},
      {:prompt => "请选择.."},
      {:onchange=>'calculate_fee(this.value)'})%>
    <span></span>
    <span id="logistic_fee" ></span><br />
    <a href="/articles/3#wlbz" target="_blank" style="margin-left:84px;">物流帮助</a><span>港澳地区请选择顺丰速运</span>
  </p>

  <p>
    <label for="order_paytype"><span style="color:red;">* </span>支付方式</label>
    <%=select("order", "paytype",Order::PAYTYPE,:prompt => "请选择..")%>
    <span></span>
  </p>
  <p style="margin-left:85px;">有开具发票等需要请在此注明:</p>
  <p>
    <label for="order_remark">附言</label>
    <%= f.text_area :remark,:rows=>'2' %>
  </p>

  <% unless session[:agent_id] %>
    <p>
      <label for="order_code">优惠码</label>
      <%= f.text_field :code,:size=>8 %>
    </p>
  <%end%>

  <% if admin? && @order.id %>
    <p>
      <label for="order_status">订单状态</label>
      <%= format_status(order.status) %>
    </p>
    <p>
      <label for="order_shipping_remark">物流单号</label>
      <%= f.text_field :shipping_remark,:size=>'10' %>
    </p>

    <p>
      <label for="order_pay_remark">付款备注</label>
      <%= f.text_area :pay_remark,:rows=>'2' %>
    </p>
  <%end%>

  <p>
    <%=image_submit_tag '/images/confirmorder.gif',:style=>"border:none;margin-left:105px;" %>
    <a href="<%=back_url%>" class="action_back" title="返回上一步">
      <img src="/images/back.gif" alt="返回上一步" />
    </a>
  </p>
<% end %>
</div>
<input type="hidden"  id="hidden_address_id" />